Skip to content

feat(quantum): native prepare/sample bridge through prepared artifact and opt-in local service - #98

Merged
AetherAI3 merged 7 commits into
mainfrom
claude/nano61-native-bridge
Nov 8, 2026
Merged

AetherAI3 merged 7 commits into
mainfrom
claude/nano61-native-bridge

Conversation

@AetherAI3

Copy link
Copy Markdown
Owner

Completes the gap left open in #61: known-bit preparation and sampling now travel through a real prepared artifact and the q-search service path, without being disguised as a QUBO/QAOA job.

  • Frozen contract: nano.quantum.native-* v1 schemas (request, profile, target, artifact, result, capabilities), PUB map, capability matrix and canonical goldens. Contract parsing is stdlib-only.
  • Offline prepared artifact: pinned Qiskit 2.3.1 circuits with QPY digests bound to plan digest, operation/preparation IDs, recipient/chunk/slot, PUB/register/bit order, evidence reference/digest, profile, target, layout and resource bounds. Loading re-verifies every circuit and refuses drift, corrupted QPY/metadata, wrong SDK/compiler and unsupported op/version before execution.
  • Opt-in local service: /qsearch/native/v1/... routes, disabled by default (ServiceConfig.native_policy=None), local ideal simulator or injected fake runtime only. Reuses existing MAC/nonce auth, durable request rows, single-attempt claim, cancellation fence and the unchanged job-state projection. No hardware target, provider call or new ledger; local results never carry a hardware seal or provider-final accounting, and unknown usage stays held.
  • Caller-side verification: results are verified against identity the caller retained, not the service's own manifest — a forged manifest resealed with the key is still rejected.
  • Scale: the 400-recipient / 1,200-PUB mapping survives actual artifact load and the local HTTP service. Explicit test caps (max_pubs=1200, max_body_bytes=8 MiB); production defaults unchanged and shown to refuse it.
  • Unchanged: legacy v1/v2 routes, schemas, defaults, to_legacy_job and optimize goldens. The q-search lifecycle wire contract v1 is untouched (status-only).
  • Negative controls: wrong width, missing/duplicate/reordered PUB, recipient/chunk collision, stale evidence bank, substituted artifact/profile/target, partial result, boundary+1 caps, wrong auth, repeated nonce, request-ID conflict, lost ack, restart, cancel races on a fake clock, and a deterministic deadline kill of a slow worker.
  • Docs: docs/quantum-native-bridge.md, status page and README now describe exactly what exists; no hardware qualification or quantum-advantage claim.

Evidence: quantum + q-search suites 1080 passed / 0 failed locally; full local suite on the integrated tree 3144 passed / 0 failed; release-conformance harness qiskit.native_bridge 81/81 (all 17 required IDs) and wheel.native_fixture PASS on two byte-identical runs. Linux matrix: this PR's CI.

Closes #61. Part of #67.

🤖 Generated with Claude Code

AetherAI3 and others added 7 commits November 7, 2026 22:11
Add stdlib-only records for the native prepare_bits/sample bridge: a
local_ideal-only target, a pinned compile profile, the ordered PUB map with
register/bit offsets and recipient/chunk/slot, declared resources, the
request descriptor and a frozen capability matrix. Unknown versions fail
with UNSUPPORTED_VERSION; optimize_qubo, hardware targets, wrong compiler
or SDK pins are refused with stable codes. Structural JSON Schemas,
fixtures and digest goldens freeze the contract before any adapter work.

Part of #61.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Admit a checked native plan and build its pinned Qiskit 2.3.1 circuits
directly (X per declared bit, measure q[i] into register[i]) with no QUBO
or QAOA fields. The artifact binds plan, PUB map, profile, target, layout,
per-PUB QPY digests and resources; circuit metadata binds the same
identity. Parsing is stdlib only and refuses substituted, missing,
duplicate or reordered PUBs. Loading needs the pinned SDK, re-checks each
circuit and requires byte equality with a fresh rebuild (DRIFT), with
stable UNAVAILABLE_DEPENDENCY / UNSUPPORTED_SDK diagnostics. A
preparation-only artifact carries no PUB, sample or execution claim. The
native request descriptor must equal its artifact.

Part of #61.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add POST /qsearch/native/v1/submit, GET .../requests/<digest> and POST
.../<digest>/cancel. They answer only when ServiceConfig.native_policy is
set (NANO_QSEARCH_NATIVE=1 plus an explicit policy file) and are otherwise
404 NOT_ENABLED before authentication. Admission checks declared resources
and the host-admitted profile/target digests from the signed descriptor
before parsing the artifact, then the artifact against the descriptor and
an optional evidence-bank registry, then a pinned QPY preflight.

The routes reuse the existing request MAC and nonce store, durable request
rows, single attempt claim, cancellation fence and the unchanged job-state
projection. Only local runtimes are accepted. Startup recovery never starts
execution; a lost local outcome stays held. Local results are sealed with a
separate native-local domain, report dry_run backend and not_applicable
accounting, and never carry a hardware seal. v1/v2 routes, schemas and
defaults are unchanged; v2 routes do not serve native rows.

Part of #61.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add retain_identity/verify_native_result: the caller binds its own plan to
the request before submission and checks every returned identity field
against that retained copy, then decodes the observations with its own plan
and evidence catalog. Execution, decoded delivery and accounting stay
separate; hardware qualification is always none.

Tests drive builder -> plan -> prepared artifact -> authenticated local
service -> pinned Qiskit ideal samples -> verified records for known-bit,
one-record and packed-record plans, and the 400-recipient/1,200-PUB fixture
over HTTP through actual QPY load. That fixture needs explicit test caps
(max_pubs=1200, max_body_bytes=8 MiB); tests show the defaults refuse it.
Negative controls cover forged manifests, hardware/accounting claims,
stale evidence, partial, missing and reordered PUBs, and a no-Qiskit
subprocess for core checking and caller verification.

Part of #61.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Address independent review findings: verify_native_result now requires the
receipt key and checks effect/reason consistency; seal errors of any type
map to SEAL. Native preflight holds a concurrency slot (SERVICE_BUSY when
none frees) so parallel QPY loads stay bounded. Corrupt durable state in
the single-flight path returns 503 STATE_UNAVAILABLE instead of escaping;
a claimed attempt stays held. Row-kind checks skip JSON parsing for
non-native rows. Tests seed unclaimed rows directly and reseal forged
records as a compromised key holder would.

Part of #61.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nistically

Tests that spawn the local runtime now use non-golden copies of the fixture
plans, built with the same builders and a 60 s wall bound (the default
policy deadline), because child startup counts against the declared bound.
Frozen goldens keep their 5 s bound and stay covered by the contract and
artifact tests. Deadline enforcement is proven independently of machine
load: a 1 s bound kills a child that sleeps 60 s and the request is sealed
FAILED; a fake runtime's DEADLINE error is sealed the same way. The local
runtime's worker command is injectable for that test; the default and the
deadline semantics are unchanged.

docs/status.md now describes the native bridge as implemented: opt-in,
disabled by default, local simulator or test fake runtime only, no hardware,
provider submission or provider accounting.

Part of #61.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The README still said prepare/sample artifact and service-wire support was
unfinished. State what now exists (pinned-Qiskit artifact, opt-in local-only
routes, disabled by default) and what does not (hardware or provider adapters).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AetherAI3
AetherAI3 merged commit 545282a into main Nov 8, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1][language] Define typed prepare, sample and optimize operations for quantum comm-ops

1 participant