qdsv-runtime 0.1.0a1__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.
- qdsv_runtime-0.1.0a1/.github/workflows/ci.yml +33 -0
- qdsv_runtime-0.1.0a1/.gitignore +16 -0
- qdsv_runtime-0.1.0a1/LICENSE +21 -0
- qdsv_runtime-0.1.0a1/PKG-INFO +134 -0
- qdsv_runtime-0.1.0a1/PUBLISHING.md +53 -0
- qdsv_runtime-0.1.0a1/README.md +108 -0
- qdsv_runtime-0.1.0a1/examples/basic.qintent +1 -0
- qdsv_runtime-0.1.0a1/examples/bridge_spec.json +24 -0
- qdsv_runtime-0.1.0a1/examples/rows.json +5 -0
- qdsv_runtime-0.1.0a1/pyproject.toml +42 -0
- qdsv_runtime-0.1.0a1/src/qdsv_runtime/__init__.py +4 -0
- qdsv_runtime-0.1.0a1/src/qdsv_runtime/cli.py +86 -0
- qdsv_runtime-0.1.0a1/src/qdsv_runtime/runtime.py +211 -0
- qdsv_runtime-0.1.0a1/tests/test_runtime_workspace.py +24 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
python-version: ["3.9", "3.11", "3.12"]
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python-version }}
|
|
22
|
+
- name: Install package
|
|
23
|
+
run: |
|
|
24
|
+
python -m pip install --upgrade pip
|
|
25
|
+
python -m pip install -e .
|
|
26
|
+
python -m pip install pytest
|
|
27
|
+
- name: Run tests
|
|
28
|
+
run: python -m pytest -q
|
|
29
|
+
- name: Smoke test CLI
|
|
30
|
+
run: |
|
|
31
|
+
qdsv --help
|
|
32
|
+
qdsv --root /tmp/qdsv-runtime-alpha init
|
|
33
|
+
qdsv --root /tmp/qdsv-runtime-alpha report
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QDSV / Qruba
|
|
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,134 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qdsv-runtime
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: QDSV Runtime Alpha: a lightweight execution layer for problem-first QDSV workflows.
|
|
5
|
+
Project-URL: Homepage, https://qdsv.cloud/
|
|
6
|
+
Project-URL: Source, https://github.com/qdsvquantum-afk/qdsv-runtime
|
|
7
|
+
Project-URL: QIntent, https://qdsvquantum-afk.github.io/qintent/
|
|
8
|
+
Project-URL: Bridge, https://qdsvquantum-afk.github.io/qdsv-bridge/
|
|
9
|
+
Project-URL: Qruba, https://qdsvquantum-afk.github.io/qruba/
|
|
10
|
+
Author: QDSV / Qruba
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: bridge,qdsv,qintent,quantum-software,runtime,semantic-workflows
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Requires-Dist: qdsv-bridge>=0.1.6
|
|
24
|
+
Requires-Dist: qdsv-qintent>=0.1.11
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# QDSV Runtime Alpha
|
|
28
|
+
|
|
29
|
+
[](#public-alpha-scope)
|
|
30
|
+
[](LICENSE)
|
|
31
|
+
|
|
32
|
+
**QDSV Runtime Alpha** is a lightweight execution layer for problem-first QDSV workflows.
|
|
33
|
+
|
|
34
|
+
It ties together the public QDSV developer stack:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
QIntent -> QDSV Runtime Alpha -> QDSV Bridge -> OpenQASM / Qiskit / reports
|
|
38
|
+
|
|
39
|
+
Qruba -> visual human interaction layer
|
|
40
|
+
QDSV -> semantic model and private engine
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Runtime Alpha does **not** embed or expose the private QDSV semantic engine. It provides a small workspace, CLI and SDK that call the public QIntent and Bridge clients, save artifacts, and generate reproducibility reports.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
For local development:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install -e .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
When published:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install qdsv-runtime
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Before the PyPI release, users can install from GitHub after the public repository is created:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install git+https://github.com/qdsvquantum-afk/qdsv-runtime.git
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## CLI Quickstart
|
|
66
|
+
|
|
67
|
+
Create a workspace:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
qdsv init
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Validate a QIntent file:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
qdsv validate examples/basic.qintent
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Build a Bridge artifact from a supported Bridge spec:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
qdsv build examples/bridge_spec.json --target bridge
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Generate a local runtime report:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
qdsv report
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Docker/private demo images can also include the same CLI:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
docker exec qruba-api-private qdsv --help
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Python SDK
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from qdsv_runtime import QDSVRuntime
|
|
101
|
+
|
|
102
|
+
runtime = QDSVRuntime()
|
|
103
|
+
runtime.init_workspace()
|
|
104
|
+
runtime.validate_intent("examples/basic.qintent")
|
|
105
|
+
runtime.build_bridge("examples/bridge_spec.json")
|
|
106
|
+
runtime.write_report()
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Public Alpha Scope
|
|
110
|
+
|
|
111
|
+
This alpha includes:
|
|
112
|
+
|
|
113
|
+
- workspace creation;
|
|
114
|
+
- QIntent validation/explain calls through the public API or configured local/private node;
|
|
115
|
+
- Bridge build calls for supported public Bridge specifications;
|
|
116
|
+
- local artifact storage;
|
|
117
|
+
- reproducibility report generation;
|
|
118
|
+
- CLI commands for small examples.
|
|
119
|
+
|
|
120
|
+
This alpha does **not** include:
|
|
121
|
+
|
|
122
|
+
- private QDSV Runtime internals;
|
|
123
|
+
- semantic compiler internals;
|
|
124
|
+
- lowering logic;
|
|
125
|
+
- backend selection internals;
|
|
126
|
+
- private scoring formulas;
|
|
127
|
+
- production scheduler;
|
|
128
|
+
- user/tenant management;
|
|
129
|
+
- marketplace/plugins;
|
|
130
|
+
- local execution of the private semantic engine.
|
|
131
|
+
|
|
132
|
+
## Positioning
|
|
133
|
+
|
|
134
|
+
QDSV Runtime Alpha is not a quantum operating system. It is an early semantic execution layer for problem-first QDSV workflows. The goal is to show how QIntent, Bridge and future visual environments such as Qruba can be tied together through a small executable layer without exposing the private engine.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Publishing QDSV Runtime Alpha
|
|
2
|
+
|
|
3
|
+
This package is prepared for PyPI as `qdsv-runtime`.
|
|
4
|
+
|
|
5
|
+
## Preflight
|
|
6
|
+
|
|
7
|
+
Run from the repository root:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
python -m pip install --upgrade build twine pytest
|
|
11
|
+
python -m pytest -q
|
|
12
|
+
python -m build
|
|
13
|
+
python -m twine check dist/*
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Expected artifacts:
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
dist/qdsv_runtime-0.1.0a1-py3-none-any.whl
|
|
20
|
+
dist/qdsv_runtime-0.1.0a1.tar.gz
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Publish to PyPI
|
|
24
|
+
|
|
25
|
+
Use a PyPI API token. Do not paste long-lived credentials into public logs.
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
$env:TWINE_USERNAME="__token__"
|
|
29
|
+
$env:TWINE_PASSWORD="pypi-..."
|
|
30
|
+
python -m twine upload dist/qdsv_runtime-0.1.0a1-py3-none-any.whl dist/qdsv_runtime-0.1.0a1.tar.gz
|
|
31
|
+
Remove-Item Env:TWINE_USERNAME
|
|
32
|
+
Remove-Item Env:TWINE_PASSWORD
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
After publishing:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install qdsv-runtime
|
|
39
|
+
qdsv --help
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Publish to GitHub
|
|
43
|
+
|
|
44
|
+
Create a public GitHub repository named `qdsv-runtime`, then run:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
git remote add origin https://github.com/qdsvquantum-afk/qdsv-runtime.git
|
|
48
|
+
git push -u origin main
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Public boundary
|
|
52
|
+
|
|
53
|
+
This package is a public Runtime Alpha shell. It does not include the private QDSV semantic engine, semantic compiler internals, lowering logic, backend-selection heuristics, private formulas, credentials, or production runtime configuration.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# QDSV Runtime Alpha
|
|
2
|
+
|
|
3
|
+
[](#public-alpha-scope)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
**QDSV Runtime Alpha** is a lightweight execution layer for problem-first QDSV workflows.
|
|
7
|
+
|
|
8
|
+
It ties together the public QDSV developer stack:
|
|
9
|
+
|
|
10
|
+
```text
|
|
11
|
+
QIntent -> QDSV Runtime Alpha -> QDSV Bridge -> OpenQASM / Qiskit / reports
|
|
12
|
+
|
|
13
|
+
Qruba -> visual human interaction layer
|
|
14
|
+
QDSV -> semantic model and private engine
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Runtime Alpha does **not** embed or expose the private QDSV semantic engine. It provides a small workspace, CLI and SDK that call the public QIntent and Bridge clients, save artifacts, and generate reproducibility reports.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
For local development:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install -e .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
When published:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install qdsv-runtime
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Before the PyPI release, users can install from GitHub after the public repository is created:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install git+https://github.com/qdsvquantum-afk/qdsv-runtime.git
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## CLI Quickstart
|
|
40
|
+
|
|
41
|
+
Create a workspace:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
qdsv init
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Validate a QIntent file:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
qdsv validate examples/basic.qintent
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Build a Bridge artifact from a supported Bridge spec:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
qdsv build examples/bridge_spec.json --target bridge
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Generate a local runtime report:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
qdsv report
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Docker/private demo images can also include the same CLI:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
docker exec qruba-api-private qdsv --help
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Python SDK
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from qdsv_runtime import QDSVRuntime
|
|
75
|
+
|
|
76
|
+
runtime = QDSVRuntime()
|
|
77
|
+
runtime.init_workspace()
|
|
78
|
+
runtime.validate_intent("examples/basic.qintent")
|
|
79
|
+
runtime.build_bridge("examples/bridge_spec.json")
|
|
80
|
+
runtime.write_report()
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Public Alpha Scope
|
|
84
|
+
|
|
85
|
+
This alpha includes:
|
|
86
|
+
|
|
87
|
+
- workspace creation;
|
|
88
|
+
- QIntent validation/explain calls through the public API or configured local/private node;
|
|
89
|
+
- Bridge build calls for supported public Bridge specifications;
|
|
90
|
+
- local artifact storage;
|
|
91
|
+
- reproducibility report generation;
|
|
92
|
+
- CLI commands for small examples.
|
|
93
|
+
|
|
94
|
+
This alpha does **not** include:
|
|
95
|
+
|
|
96
|
+
- private QDSV Runtime internals;
|
|
97
|
+
- semantic compiler internals;
|
|
98
|
+
- lowering logic;
|
|
99
|
+
- backend selection internals;
|
|
100
|
+
- private scoring formulas;
|
|
101
|
+
- production scheduler;
|
|
102
|
+
- user/tenant management;
|
|
103
|
+
- marketplace/plugins;
|
|
104
|
+
- local execution of the private semantic engine.
|
|
105
|
+
|
|
106
|
+
## Positioning
|
|
107
|
+
|
|
108
|
+
QDSV Runtime Alpha is not a quantum operating system. It is an early semantic execution layer for problem-first QDSV workflows. The goal is to show how QIntent, Bridge and future visual environments such as Qruba can be tied together through a small executable layer without exposing the private engine.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
find_rows("candidate_index").where("score", ">=", 850).rank_by("score").top_k(2)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"family": "bounded_semantic_marking",
|
|
3
|
+
"bridge_mode": "build",
|
|
4
|
+
"name": "runtime_alpha_demo",
|
|
5
|
+
"description": "Small public Runtime Alpha example for Bridge handoff.",
|
|
6
|
+
"state_space": {
|
|
7
|
+
"kind": "finite_candidates",
|
|
8
|
+
"candidate_count": 8,
|
|
9
|
+
"candidate_id": "candidate"
|
|
10
|
+
},
|
|
11
|
+
"signals": ["eligibility_score", "risk_score"],
|
|
12
|
+
"goal": {
|
|
13
|
+
"kind": "marking",
|
|
14
|
+
"predicate": "eligible_candidate"
|
|
15
|
+
},
|
|
16
|
+
"target": {
|
|
17
|
+
"format": "qasm3",
|
|
18
|
+
"backend_family": "qiskit"
|
|
19
|
+
},
|
|
20
|
+
"limits": {
|
|
21
|
+
"max_qubits": 5,
|
|
22
|
+
"max_depth": 160
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.25"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "qdsv-runtime"
|
|
7
|
+
version = "0.1.0a1"
|
|
8
|
+
description = "QDSV Runtime Alpha: a lightweight execution layer for problem-first QDSV workflows."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "QDSV / Qruba" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["qdsv", "runtime", "qintent", "bridge", "semantic-workflows", "quantum-software"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Intended Audience :: Science/Research",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
23
|
+
"Topic :: Scientific/Engineering",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"qdsv-qintent>=0.1.11",
|
|
28
|
+
"qdsv-bridge>=0.1.6",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://qdsv.cloud/"
|
|
33
|
+
Source = "https://github.com/qdsvquantum-afk/qdsv-runtime"
|
|
34
|
+
QIntent = "https://qdsvquantum-afk.github.io/qintent/"
|
|
35
|
+
Bridge = "https://qdsvquantum-afk.github.io/qdsv-bridge/"
|
|
36
|
+
Qruba = "https://qdsvquantum-afk.github.io/qruba/"
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
qdsv = "qdsv_runtime.cli:main"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
packages = ["src/qdsv_runtime"]
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from .runtime import QDSVRuntime
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
11
|
+
parser = argparse.ArgumentParser(
|
|
12
|
+
prog="qdsv",
|
|
13
|
+
description="QDSV Runtime Alpha CLI for problem-first QDSV workflows.",
|
|
14
|
+
)
|
|
15
|
+
parser.add_argument("--root", default=".", help="Workspace root directory.")
|
|
16
|
+
parser.add_argument("--api-url", default=None, help="QDSV API base URL.")
|
|
17
|
+
parser.add_argument("--local", action="store_true", help="Use local/private Docker API.")
|
|
18
|
+
parser.add_argument("--timeout", type=float, default=30.0, help="Request timeout in seconds.")
|
|
19
|
+
|
|
20
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
21
|
+
|
|
22
|
+
init = sub.add_parser("init", help="Create a QDSV Runtime Alpha workspace.")
|
|
23
|
+
init.add_argument("--force", action="store_true", help="Overwrite generated examples.")
|
|
24
|
+
|
|
25
|
+
validate = sub.add_parser("validate", help="Validate a QIntent file.")
|
|
26
|
+
validate.add_argument("source", help="Path to .qintent source.")
|
|
27
|
+
validate.add_argument("--rows", default=None, help="Optional rows JSON file.")
|
|
28
|
+
validate.add_argument("--backend", default="quest", help="Requested backend for QIntent.")
|
|
29
|
+
validate.add_argument("--shots", type=int, default=256, help="Requested shots.")
|
|
30
|
+
|
|
31
|
+
explain = sub.add_parser("explain", help="Explain a QIntent file.")
|
|
32
|
+
explain.add_argument("source", help="Path to .qintent source.")
|
|
33
|
+
explain.add_argument("--rows", default=None, help="Optional rows JSON file.")
|
|
34
|
+
explain.add_argument("--backend", default="quest", help="Requested backend for QIntent.")
|
|
35
|
+
explain.add_argument("--shots", type=int, default=256, help="Requested shots.")
|
|
36
|
+
|
|
37
|
+
build = sub.add_parser("build", help="Build a target artifact.")
|
|
38
|
+
build.add_argument("input", help="Input file. For --target bridge, use a Bridge spec JSON.")
|
|
39
|
+
build.add_argument("--target", choices=["bridge"], default="bridge", help="Build target.")
|
|
40
|
+
|
|
41
|
+
report = sub.add_parser("report", help="Generate a local runtime report.")
|
|
42
|
+
report.add_argument("--title", default="QDSV Runtime Alpha Report", help="Report title.")
|
|
43
|
+
|
|
44
|
+
return parser
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def main(argv: list[str] | None = None) -> int:
|
|
48
|
+
parser = build_parser()
|
|
49
|
+
args = parser.parse_args(argv)
|
|
50
|
+
runtime = QDSVRuntime(root=args.root, api_url=args.api_url, local=args.local, timeout=args.timeout)
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
if args.command == "init":
|
|
54
|
+
workspace = runtime.init_workspace(force=args.force)
|
|
55
|
+
print(f"QDSV workspace ready: {Path(args.root).resolve() / '.qdsv'}")
|
|
56
|
+
print(f"Runtime: {workspace['runtime']}")
|
|
57
|
+
return 0
|
|
58
|
+
if args.command == "validate":
|
|
59
|
+
artifact = runtime.validate_intent(args.source, rows_path=args.rows, backend=args.backend, shots=args.shots)
|
|
60
|
+
print("QIntent validation artifact saved.")
|
|
61
|
+
print(f"Status: {artifact['payload'].get('status', 'UNKNOWN')}")
|
|
62
|
+
return 0
|
|
63
|
+
if args.command == "explain":
|
|
64
|
+
artifact = runtime.explain_intent(args.source, rows_path=args.rows, backend=args.backend, shots=args.shots)
|
|
65
|
+
print("QIntent explain artifact saved.")
|
|
66
|
+
print(f"Status: {artifact['payload'].get('status', 'UNKNOWN')}")
|
|
67
|
+
return 0
|
|
68
|
+
if args.command == "build":
|
|
69
|
+
artifact = runtime.build_bridge(args.input)
|
|
70
|
+
print("Bridge build artifact saved.")
|
|
71
|
+
print(f"Status: {artifact['payload'].get('status', 'UNKNOWN')}")
|
|
72
|
+
return 0
|
|
73
|
+
if args.command == "report":
|
|
74
|
+
report_path = runtime.write_report(title=args.title)
|
|
75
|
+
print(f"Runtime report written: {report_path}")
|
|
76
|
+
return 0
|
|
77
|
+
except Exception as exc: # pragma: no cover - CLI boundary
|
|
78
|
+
print(f"ERROR: {exc}", file=sys.stderr)
|
|
79
|
+
return 1
|
|
80
|
+
|
|
81
|
+
parser.print_help()
|
|
82
|
+
return 2
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
if __name__ == "__main__": # pragma: no cover
|
|
86
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from datetime import datetime, timezone
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any, Mapping
|
|
8
|
+
|
|
9
|
+
from qdsv_bridge import QDSVBridgeClient
|
|
10
|
+
from qintent import QIntentClient
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
WORKSPACE_DIR = ".qdsv"
|
|
14
|
+
ARTIFACTS_DIR = "artifacts"
|
|
15
|
+
REPORTS_DIR = "reports"
|
|
16
|
+
WORKSPACE_FILE = "workspace.json"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class QDSVRuntime:
|
|
21
|
+
"""Small public execution layer for QDSV developer workflows.
|
|
22
|
+
|
|
23
|
+
Runtime Alpha orchestrates public SDK calls and local artifacts. It does
|
|
24
|
+
not embed or expose the private QDSV semantic engine.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
root: str | Path = "."
|
|
28
|
+
api_url: str | None = None
|
|
29
|
+
local: bool = False
|
|
30
|
+
timeout: float = 30.0
|
|
31
|
+
|
|
32
|
+
def __post_init__(self) -> None:
|
|
33
|
+
self.root_path = Path(self.root).resolve()
|
|
34
|
+
if self.local:
|
|
35
|
+
self.qintent = QIntentClient.local(timeout=self.timeout)
|
|
36
|
+
self.bridge = QDSVBridgeClient.local(timeout=self.timeout)
|
|
37
|
+
else:
|
|
38
|
+
self.qintent = QIntentClient(api_url=self.api_url, timeout=self.timeout)
|
|
39
|
+
self.bridge = QDSVBridgeClient(api_url=self.api_url, timeout=self.timeout)
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def workspace_path(self) -> Path:
|
|
43
|
+
return self.root_path / WORKSPACE_DIR
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def artifacts_path(self) -> Path:
|
|
47
|
+
return self.workspace_path / ARTIFACTS_DIR
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def reports_path(self) -> Path:
|
|
51
|
+
return self.workspace_path / REPORTS_DIR
|
|
52
|
+
|
|
53
|
+
def init_workspace(self, *, force: bool = False) -> dict[str, Any]:
|
|
54
|
+
self.workspace_path.mkdir(parents=True, exist_ok=True)
|
|
55
|
+
self.artifacts_path.mkdir(parents=True, exist_ok=True)
|
|
56
|
+
self.reports_path.mkdir(parents=True, exist_ok=True)
|
|
57
|
+
examples_path = self.root_path / "examples"
|
|
58
|
+
examples_path.mkdir(parents=True, exist_ok=True)
|
|
59
|
+
|
|
60
|
+
workspace = {
|
|
61
|
+
"name": self.root_path.name,
|
|
62
|
+
"runtime": "qdsv-runtime-alpha",
|
|
63
|
+
"version": "0.1.0a1",
|
|
64
|
+
"created_at": self._now(),
|
|
65
|
+
"engine_exposed": False,
|
|
66
|
+
"default_api_route": "local" if self.local else "public",
|
|
67
|
+
"artifacts_dir": str(self.artifacts_path.relative_to(self.root_path)),
|
|
68
|
+
"reports_dir": str(self.reports_path.relative_to(self.root_path)),
|
|
69
|
+
}
|
|
70
|
+
workspace_file = self.workspace_path / WORKSPACE_FILE
|
|
71
|
+
if force or not workspace_file.exists():
|
|
72
|
+
self._write_json(workspace_file, workspace)
|
|
73
|
+
|
|
74
|
+
qintent_example = examples_path / "basic.qintent"
|
|
75
|
+
if force or not qintent_example.exists():
|
|
76
|
+
qintent_example.write_text(
|
|
77
|
+
'find_rows("candidate_index").where("score", ">=", 850).rank_by("score").top_k(2)\n',
|
|
78
|
+
encoding="utf-8",
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
rows_example = examples_path / "rows.json"
|
|
82
|
+
if force or not rows_example.exists():
|
|
83
|
+
self._write_json(
|
|
84
|
+
rows_example,
|
|
85
|
+
[
|
|
86
|
+
{"candidate_index": 0, "score": 720, "risk_ok": True},
|
|
87
|
+
{"candidate_index": 1, "score": 910, "risk_ok": True},
|
|
88
|
+
{"candidate_index": 2, "score": 840, "risk_ok": False},
|
|
89
|
+
],
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
bridge_example = examples_path / "bridge_spec.json"
|
|
93
|
+
if force or not bridge_example.exists():
|
|
94
|
+
self._write_json(
|
|
95
|
+
bridge_example,
|
|
96
|
+
{
|
|
97
|
+
"family": "bounded_semantic_marking",
|
|
98
|
+
"bridge_mode": "build",
|
|
99
|
+
"name": "runtime_alpha_demo",
|
|
100
|
+
"description": "Small public Runtime Alpha example for Bridge handoff.",
|
|
101
|
+
"state_space": {
|
|
102
|
+
"kind": "finite_candidates",
|
|
103
|
+
"candidate_count": 8,
|
|
104
|
+
"candidate_id": "candidate",
|
|
105
|
+
},
|
|
106
|
+
"signals": ["eligibility_score", "risk_score"],
|
|
107
|
+
"goal": {
|
|
108
|
+
"kind": "marking",
|
|
109
|
+
"predicate": "eligible_candidate",
|
|
110
|
+
},
|
|
111
|
+
"target": {"format": "qasm3", "backend_family": "qiskit"},
|
|
112
|
+
"limits": {"max_qubits": 5, "max_depth": 160},
|
|
113
|
+
},
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
return workspace
|
|
117
|
+
|
|
118
|
+
def validate_intent(
|
|
119
|
+
self,
|
|
120
|
+
source_path: str | Path,
|
|
121
|
+
*,
|
|
122
|
+
rows_path: str | Path | None = None,
|
|
123
|
+
backend: str = "quest",
|
|
124
|
+
shots: int = 256,
|
|
125
|
+
) -> dict[str, Any]:
|
|
126
|
+
source = self._read_text(source_path)
|
|
127
|
+
rows = self._read_json(rows_path) if rows_path else None
|
|
128
|
+
payload = self.qintent.validate(source, rows=rows, backend=backend, shots=shots)
|
|
129
|
+
return self._save_artifact("qintent-validate", payload)
|
|
130
|
+
|
|
131
|
+
def explain_intent(
|
|
132
|
+
self,
|
|
133
|
+
source_path: str | Path,
|
|
134
|
+
*,
|
|
135
|
+
rows_path: str | Path | None = None,
|
|
136
|
+
backend: str = "quest",
|
|
137
|
+
shots: int = 256,
|
|
138
|
+
) -> dict[str, Any]:
|
|
139
|
+
source = self._read_text(source_path)
|
|
140
|
+
rows = self._read_json(rows_path) if rows_path else None
|
|
141
|
+
payload = self.qintent.explain(source, rows=rows, backend=backend, shots=shots)
|
|
142
|
+
return self._save_artifact("qintent-explain", payload)
|
|
143
|
+
|
|
144
|
+
def build_bridge(self, spec_path: str | Path) -> dict[str, Any]:
|
|
145
|
+
spec = self._read_json(spec_path)
|
|
146
|
+
if not isinstance(spec, Mapping):
|
|
147
|
+
raise ValueError("Bridge spec must be a JSON object.")
|
|
148
|
+
payload = self.bridge.build(spec)
|
|
149
|
+
return self._save_artifact("bridge-build", payload)
|
|
150
|
+
|
|
151
|
+
def write_report(self, *, title: str = "QDSV Runtime Alpha Report") -> Path:
|
|
152
|
+
self.reports_path.mkdir(parents=True, exist_ok=True)
|
|
153
|
+
artifacts = sorted(self.artifacts_path.glob("*.json"))
|
|
154
|
+
lines = [
|
|
155
|
+
f"# {title}",
|
|
156
|
+
"",
|
|
157
|
+
f"- Generated at: {self._now()}",
|
|
158
|
+
"- Runtime: qdsv-runtime-alpha",
|
|
159
|
+
"- Private semantic engine exposed: no",
|
|
160
|
+
"- Purpose: tie QIntent and Bridge into a reproducible public workflow.",
|
|
161
|
+
"",
|
|
162
|
+
"## Artifacts",
|
|
163
|
+
"",
|
|
164
|
+
]
|
|
165
|
+
if not artifacts:
|
|
166
|
+
lines.append("No artifacts found yet.")
|
|
167
|
+
for artifact in artifacts:
|
|
168
|
+
lines.append(f"- `{artifact.relative_to(self.root_path)}`")
|
|
169
|
+
lines.extend(
|
|
170
|
+
[
|
|
171
|
+
"",
|
|
172
|
+
"## Public Alpha Boundary",
|
|
173
|
+
"",
|
|
174
|
+
"This report was generated by the public Runtime Alpha shell. It does not include private QDSV semantic compiler internals, lowering logic, backend-selection heuristics, private formulas, credentials, or production runtime configuration.",
|
|
175
|
+
"",
|
|
176
|
+
]
|
|
177
|
+
)
|
|
178
|
+
report_path = self.reports_path / "runtime-report.md"
|
|
179
|
+
report_path.write_text("\n".join(lines), encoding="utf-8")
|
|
180
|
+
return report_path
|
|
181
|
+
|
|
182
|
+
def _save_artifact(self, name: str, payload: Mapping[str, Any]) -> dict[str, Any]:
|
|
183
|
+
self.artifacts_path.mkdir(parents=True, exist_ok=True)
|
|
184
|
+
artifact = {
|
|
185
|
+
"runtime": "qdsv-runtime-alpha",
|
|
186
|
+
"generated_at": self._now(),
|
|
187
|
+
"engine_exposed": False,
|
|
188
|
+
"artifact_kind": name,
|
|
189
|
+
"payload": dict(payload),
|
|
190
|
+
}
|
|
191
|
+
path = self.artifacts_path / f"{name}.json"
|
|
192
|
+
self._write_json(path, artifact)
|
|
193
|
+
return artifact
|
|
194
|
+
|
|
195
|
+
def _read_text(self, path: str | Path) -> str:
|
|
196
|
+
return (self.root_path / path).read_text(encoding="utf-8") if not Path(path).is_absolute() else Path(path).read_text(encoding="utf-8")
|
|
197
|
+
|
|
198
|
+
def _read_json(self, path: str | Path | None) -> Any:
|
|
199
|
+
if path is None:
|
|
200
|
+
return None
|
|
201
|
+
full_path = self.root_path / path if not Path(path).is_absolute() else Path(path)
|
|
202
|
+
return json.loads(full_path.read_text(encoding="utf-8"))
|
|
203
|
+
|
|
204
|
+
@staticmethod
|
|
205
|
+
def _write_json(path: Path, payload: Any) -> None:
|
|
206
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
207
|
+
path.write_text(json.dumps(payload, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
208
|
+
|
|
209
|
+
@staticmethod
|
|
210
|
+
def _now() -> str:
|
|
211
|
+
return datetime.now(timezone.utc).isoformat(timespec="seconds")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from qdsv_runtime import QDSVRuntime
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_init_workspace_creates_expected_files(tmp_path: Path) -> None:
|
|
7
|
+
runtime = QDSVRuntime(root=tmp_path)
|
|
8
|
+
workspace = runtime.init_workspace()
|
|
9
|
+
|
|
10
|
+
assert workspace["runtime"] == "qdsv-runtime-alpha"
|
|
11
|
+
assert workspace["engine_exposed"] is False
|
|
12
|
+
assert (tmp_path / ".qdsv" / "workspace.json").exists()
|
|
13
|
+
assert (tmp_path / "examples" / "basic.qintent").exists()
|
|
14
|
+
assert (tmp_path / "examples" / "bridge_spec.json").exists()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_report_mentions_public_boundary(tmp_path: Path) -> None:
|
|
18
|
+
runtime = QDSVRuntime(root=tmp_path)
|
|
19
|
+
runtime.init_workspace()
|
|
20
|
+
report = runtime.write_report()
|
|
21
|
+
text = report.read_text(encoding="utf-8")
|
|
22
|
+
|
|
23
|
+
assert "Private semantic engine exposed: no" in text
|
|
24
|
+
assert "does not include private QDSV semantic compiler internals" in text
|