qdsv-runtime 0.1.0a1__py3-none-any.whl

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.
@@ -0,0 +1,4 @@
1
+ from .runtime import QDSVRuntime
2
+
3
+ __all__ = ["QDSVRuntime"]
4
+ __version__ = "0.1.0a1"
qdsv_runtime/cli.py ADDED
@@ -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,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
+ [![Status](https://img.shields.io/badge/status-alpha-f59e0b.svg)](#public-alpha-scope)
30
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](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,8 @@
1
+ qdsv_runtime/__init__.py,sha256=JVS-0cYDQ6nBN62L4KqvtWszrNzpP-bjZM1CFOjdhcw,84
2
+ qdsv_runtime/cli.py,sha256=jmi_Z0DsahGe6npK6tI58LXS6Mkey0kfvO7FdkKDuMI,3945
3
+ qdsv_runtime/runtime.py,sha256=XOcR2nNE78taJCGppR6kpa3pUUKpHZynFEN2gDnOKLU,8161
4
+ qdsv_runtime-0.1.0a1.dist-info/METADATA,sha256=stTL3hQQmwXzHQB6jJmG2gftk6YE9pD756h4jOh_HV8,3782
5
+ qdsv_runtime-0.1.0a1.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
6
+ qdsv_runtime-0.1.0a1.dist-info/entry_points.txt,sha256=0aTstFYWJpySnGuEIdLT0VRZt5-WQYvM-ELXTKP-JVg,47
7
+ qdsv_runtime-0.1.0a1.dist-info/licenses/LICENSE,sha256=yoNayV2fcGyHGUbPl4faQjXbfKFiirxIDiC9RcTokhs,1069
8
+ qdsv_runtime-0.1.0a1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ qdsv = qdsv_runtime.cli:main
@@ -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.